﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Entidades;
using System.Data.OracleClient;
using System.Data;
using System.Configuration;

namespace Datos
{
   public class LoginAD
    {
       public static bool Autenticar(string Rut,int Id,string Pass)
       {
           string hash = Helper.EncodePassword(string.Concat(Rut, Pass));
           string sql = @"select	 RUTUSUARIO,
                                     ID_TIPOUSUARIO,
	                                 CONTRASENA,
	                                 ESTADO
	                        from   	 USUARIO 
	                        where    RUTUSUARIO = '" + Rut + "' and id_tipousuario = "+ Id +" and contrasena = '"+ hash +"' and estado = 'Activo'";


           


           OracleConnection Oraclecon = new OracleConnection("Server=XE;Uid=juan;Pwd=lagartija");
           Oraclecon.Open();
           OracleCommand myCMD = new OracleCommand();
           myCMD.Connection = Oraclecon;
           myCMD.CommandText = sql;
           myCMD.CommandType = CommandType.Text;

        


           int count = Convert.ToInt32(myCMD.ExecuteScalar());

           if (count == 0)
               return false;
           else
               return true;


       }

      
    }



  
}
